Skip to content

refactor(mockui): naming & structural cleanup#22

Merged
maggo83 merged 6 commits intok9ert:mainfrom
maggo83:refactor/mockui-cleanup
Mar 11, 2026
Merged

refactor(mockui): naming & structural cleanup#22
maggo83 merged 6 commits intok9ert:mainfrom
maggo83:refactor/mockui-cleanup

Conversation

@maggo83
Copy link
Copy Markdown
Collaborator

@maggo83 maggo83 commented Mar 10, 2026

What & Why

Six focused refactoring commits on top of PR #21, cleaning up naming
inconsistencies and fixing a structural mistake in the MockUI module.
No behaviour changes — purely cosmetic/structural.

Commits

NavigationControllerSpecterGui
The class is the top-level GUI root widget, not a generic controller.
Renamed file and class across all call sites.

helpers/stubs/
The directory holds placeholder implementations of UIState,
SpecterState, Battery, Wallet — to be replaced by real Specter
business logic later. stubs/ makes that intent explicit.

self.parentself.gui in TitledScreen + enforce shorthands
self.parent clashed with LVGL's own widget-parent concept, causing
confusion. Renamed to self.gui. Also audited all screen subclasses to
consistently use the self.state, self.i18n, self.on_navigate
shorthands instead of bypassing them.

parentgui in DeviceBar/WalletBar; on_navigate(None) for back
Same rename in the bar classes. Standardised back navigation to always
use self.on_navigate(None) in screens.

GenerateSeedMenu / PassphraseMenu: GenericMenuTitledScreen
Both classes inherited from GenericMenu but never used its
menu-building machinery (_build_menu_items). They are forms, not
menus — TitledScreen is the correct base class.

gitignore: **/translation_keys.py and **/language_config.json
Both are auto-generated by make sync-i18n / make build-i18n.
Using repo-wide globs instead of path-specific entries.

Tests

✅ 119 unit tests
✅ 9 device integration tests (STM32F469 Discovery board)

maggo83 added 6 commits March 10, 2026 20:03
…oller.py -> specter_gui.py)

The class and module name NavigationController was too generic and didn't
reflect the role of this central UI object. SpecterGui better expresses
that this is the top-level GUI root for the Specter device UI.

- Renamed basic/navigation_controller.py to basic/specter_gui.py
- Renamed class NavigationController to SpecterGui throughout
- Updated all imports, __all__ exports, comments and docstrings
- Updated README docs and MOCKUI_PROGRESS.md
…implementations

The classes in helpers/ (UIState, SpecterState, Battery, Wallet) are
stub implementations that will later be replaced by real Specter business
logic. Renaming to stubs/ makes that intent explicit.

- Renamed MockUI/helpers/ directory to MockUI/stubs/
- Updated all imports across basic/, wallet/, __init__.py and tests/
…rthands

TitledScreen now exposes self.gui (the SpecterGui root) instead of
self.parent, avoiding confusion with LVGL's widget parent concept.

Subclasses should use:
  self.gui   - for SpecterGui-specific methods (show_menu, refresh_ui,
               ui_state, keyboard_manager, change_language)
  self.state - shorthand for gui.specter_state (no bypass)
  self.i18n  - shorthand for gui.i18n (no bypass)
  self.on_navigate - shorthand for gui.on_navigate (no bypass)

- Removed redundant setattr(self.parent.specter_state, ...) in
  interfaces_menu (self.state is the same object)
- Fixed language_menu, settings_menu to use self.i18n shorthand
- Fixed all keyboard_manager references to use self.gui
…e(None) for back

- DeviceBar, WalletBar: rename self.parent -> self.gui (consistent with
  TitledScreen refactor); keep self.gui.show_menu() for forward navigation
  to specific menus (more readable at the call site than on_navigate)
- locked_menu, generate_seedphrase_menu: replace self.gui.show_menu(None)
  with self.on_navigate(None) — these are "go back" calls and should use
  the standard TitledScreen callback
…u to TitledScreen

Both classes are forms, not menus — they don't use get_menu_items() or
_build_menu_items() at all, only post_init(). Subclassing GenericMenu was
semantically misleading and added unnecessary indirection.

Changes:
- Inherit from TitledScreen instead of GenericMenu
- Replace TITLE_KEY + post_init(t, state) with a plain __init__(parent)
- Translate title via parent.i18n.t() before calling super().__init__()
- Set up body flex layout explicitly (was done implicitly by GenericMenu)
- Use t = self.i18n.t local alias for translations (self.state accessed directly)
- Drop unused imports: RED, ORANGE, GREEN
@maggo83 maggo83 merged commit 19d5e0e into k9ert:main Mar 11, 2026
1 check passed
@maggo83 maggo83 deleted the refactor/mockui-cleanup branch March 16, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant